package com.youxuit.youxu.kecheng.SynchronizedDemo;

public class UnSafeShowSolve1 implements Runnable{

    public static UnSafeShowSolve1 unSafeShow1 = new UnSafeShowSolve1();
    public static int j = 0;


    @Override
    public void run() {
        synchronized (this) {
            for (int i = 0; i < 10000; i++) {
                j = j + 1;
            }
        }
    }
    /*@Override
    public void run() {
        synchronized (UnSafeShowSolve1.class) {
            for (int i = 0; i < 10000; i++) {
                j = j + 1;
            }
        }
    }*/

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(unSafeShow1);
        Thread t2 = new Thread(unSafeShow1);
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(j);
    }
}
